package per.jdz.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import per.jdz.entity.RestBean;

import java.security.Principal;

/**
 * ClassName: CurrentLoginUserInfoController
 * Description:
 *
 * @Author: jdz
 * @Create: 2023/4/20 - 1:22
 */
@RestController
@RequestMapping("/api/user/t")
public class CurrentLoginUserInfoController {
    /**
     * 通过安全上下文持有器获取安全上下文，再获取认证信息
     * */
    @GetMapping("/getUserInfo")
    public RestBean<String> getUserInfo() {
        return RestBean.success(String.valueOf(SecurityContextHolder.getContext().getAuthentication()));
    }
}
